<template>
	<div class="zhengtuojianhuo">
		<van-nav-bar :fixed="true" class="navBar" title="结束容器" left-arrow @click-left="$router.go(-1)"></van-nav-bar>

		<div class="goodsFromWarp">
				<div class="goodsInputWarp">
						<div class="goodsInputLabel">
							<div class="goodsInputBorder"></div>
							<div class="skuName">波次单号：</div>
						</div>

						<div class="skuNoInput">
							{{jieshuData[0].bill}}
						</div>
				</div>
				<div class="goodsInputWarp">
						<div class="goodsInputLabel">
							<div class="goodsInputBorder"></div>
							<div class="skuName">门店：</div>
						</div>

						<div class="skuNoInput">
							{{jieshuData[0].ck_storeid}}-{{jieshuData[0].storename}}
						</div>
				</div>


				<div class="goodsInputWarp">
						<div class="goodsInputLabel" style="width:35%;">
							<div class="goodsInputBorder"></div>
							<div class="skuName" style="width: 120px;">拣货标签：</div>
						</div>
						<van-field
							 class="skuInput"
							 v-model="jhrqid"
							 placeholder="请填写拣货标签"
						 />
				</div>

				<div class="savefooterBtn" style="margin-bottom: 10px;">
					<van-button style="margin-left:20px;" type="info"  @click="savejieShuClickBtn()">任务完成</van-button>
				</div>

		</div>


		<div class="carCardWarp">
			<div class="carCard" v-for="(item,index) in jieshuData" :key="index">
				<van-row class="goodRow" >
				  <van-col span="24"> <span>任务号:</span>{{item.bill}}</van-col>
				</van-row>

				<van-row class="goodRow" >
				  <van-col span="24"> <span>条码:</span>{{item.barcode}}</van-col>
				</van-row>

				<div class="goodsTitleRow">
						<div class="goodsTitleLabel">
							<div class="skuName">商品：</div>
						</div>
						<div class="skuNoTitle">
						{{item.subsname}}
						</div>
				</div>






				<van-row class="goodRow" style="margin-top: 10px;">
				  <van-col span="12"> <span>箱装:</span> {{item.unit}}</van-col>
				  <van-col span="12"> <span>箱数:</span>{{item.pack}}</van-col>
				</van-row>

				<van-row class="goodRow" style="margin-top: 10px;">
				  <van-col span="12"> <span>总数量:</span>{{item.yjtotqty}}</van-col>
				</van-row>



			</div>
		</div>



	</div>
</template>

<script>

export default {
  name: 'longchejieshu',
  data() {
    return {
			editForm:{},
			jieshuData:[
				{
					bill:'',
					ck_storeid:'',
					storename:'',
				}
			],
			isdisabled:'',
			jhrqid:'',
			hzyjtotqty:'',
		};
  },
  // 添加 activated 钩子，确保每次进入页面都重新加载数据
  activated() {
      console.log("结束数据")
      this.editForm = JSON.parse(this.$route.query.editForm)
      this._getSku()

  },
  //
	computed: {
	   ryuser: function(){
	     return this.GWO(true).gUSER;
	   }
	},
  methods: {
		savejieShuClickBtn(){
			console.log(this.editForm.bill)
			var _self = this;
			var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			this.MYPOST({
					'method':'dgate',
					'pname':'f_wmsa_y_jianhuo',
					'i':this.FNULLE([
					'opmode','Y_LONGCHE_jsrq',
					'kqid', this.ryuser.kqid,
					'czyid',this.ryuser.operatorid,
					'bill', this.jieshuData[0].bill,
					'jhrqid', this.jhrqid,
					'hzyjtotqty',this.hzyjtotqty,
				])
				}, '结束容器提交',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
				if(ret_iserr){ //传入的true参数,理论上不会有此回调了
					_self.$toast.fail('查询失败')
					_self.$store.commit('hideLoading');
				}else{
					var rtn_json_obj = null;
					_self.$store.commit('hideLoading');
					if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
					}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
					}
					console.log("得到结束容器提交")
					console.log(rtn_json_obj)
					if(rtn_json_obj[0].ret_ret == '-1'){
						_self.$toast.fail(rtn_json_obj[0].ret_mess)
						return
					}else{
						_self.$toast.fail(rtn_json_obj[0].ret_mess)
						_self.$router.go(-1)
					}
				}
			});
		},
		_getSku(){
			console.log(this.editForm.bill)
			var _self = this;
			var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			this.MYPOST({
					'method':'dgate',
					'pname':'f_wmsa_y_jianhuo',
					'i':this.FNULLE([
					'opmode','Y_LONGCHE_jsrq_qry',
					'kqid', this.ryuser.kqid,
					'czyid',this.ryuser.operatorid,
					'bill', this.editForm.bill,
				])
				}, '结束容器',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
				if(ret_iserr){ //传入的true参数,理论上不会有此回调了
					_self.$toast.fail('查询失败')
					_self.$store.commit('hideLoading');
				}else{
					var rtn_json_obj = null;
					_self.$store.commit('hideLoading');
					if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
					}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
					}
					console.log("得到结束容器")
					console.log(rtn_json_obj)
					_self.jieshuData = rtn_json_obj
					_self.hzyjtotqty = _self.jieshuData[0].hzyjtotqty
				}
			});
		},
  },
  mounted() {
		 console.log("结束数据")
		 this.editForm =JSON.parse(this.$route.query.editForm)
		 console.log(this.editForm)
		 this._getSku();
  },
	components: {

	},
};
</script>

<style lang="scss" scoped>
	// 引入公共样式
	@import '@/assets/css/base.scss';
	@import '@/assets/css/input.scss';
	div.zhengtuojianhuo{
		padding-top: 50px;
	}


	div.carCardWarp{
		width: 94%;
		margin-left: 3%;
		margin-right: 3%;
		margin-top: 20px;
		font-size: 14px;
		font-size: 20px;
		font-weight: bold;
		div.carCard{
			border-left: 5px solid #4998FF;
			box-sizing: border-box;
			padding-left: 10px;
			padding-right: 10px;
			border-radius:5px;
			background-color: #fff;
			padding-top: 10px;
			padding-bottom: 10px;
			margin-bottom:15px;
			div.goodRow{
				margin-bottom:8px;
				span{
					display: inline-block;
					width:80px;
				}
			}
			div.goodsTitleRow{
				display: flex;
				width: 100%;
				div.goodsTitleLabel{
					width: 80px;
				}
				div.skuNoTitle{
					width: calc(100% - 80px);
				}
			}
		}
	}


	.savefooterBtn{
		display: flex;
		justify-content: flex-end;
		// margin-top: 20px;
		button{
			border-radius: 20px;
			width: 120px;
			height: 45px;
			font-weight: bold;
			font-size: 20px;
		}
	}

</style>
